package com.slz3.business.module.messageManagement.mesTemplate.steward;

import com.slz3.business.frame.response.RR;
import com.slz3.business.frame.response.ResInfo;
import com.slz3.business.module.messageManagement.mesTemplate.domain.MesTemplate;
import com.slz3.business.module.messageManagement.mesTemplate.domain.MesTemplateCondition;
import org.springframework.stereotype.Controller;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

@Controller
public class MesTemplateResController {

    @Resource
    private MesTemplateResAtomic mesTemplateResAtomic;

    public Mono<ServerResponse> add(ServerRequest req, MesTemplate mesTemplate) {
        if (MesTemplateResUnsafeValid.add(req, mesTemplate)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTemplateResAtomic.add_$MesTemplateUpdateLock(req, mesTemplate);
        }
    }

    public Mono<ServerResponse> delete(ServerRequest req, MesTemplateCondition mesTemplateCondition) {
        if (MesTemplateResUnsafeValid.delete(req, mesTemplateCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTemplateResAtomic.delete_$MesTemplateUpdateLock(req, mesTemplateCondition);
        }
    }

    public Mono<ServerResponse> modify(ServerRequest req, MesTemplate mesTemplate) {
        if (MesTemplateResUnsafeValid.modify(req, mesTemplate)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTemplateResAtomic.modify_$MesTemplateUpdateLock(req, mesTemplate);
        }
    }

    public Mono<ServerResponse> list(ServerRequest req) {
        if (MesTemplateResUnsafeValid.list(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return MesTemplateResExecutor.list(req);
        }
    }

    public Mono<ServerResponse> info(ServerRequest req) {
//        return mesTemplateResAtomic.info_$MesTemplateUpdateLock(req);
        if (MesTemplateResUnsafeValid.info(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTemplateResAtomic.info_$MesTemplateUpdateLock(req);
        }
    }

    public Mono<ServerResponse> choice(ServerRequest req) {
        if (MesTemplateResUnsafeValid.choice(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return MesTemplateResExecutor.choice(req);
        }
    }

    public Mono<ServerResponse> auditSubmit(ServerRequest req, MesTemplateCondition mesTemplateCondition) {
        //
        if (MesTemplateResUnsafeValid.auditSubmit(req, mesTemplateCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTemplateResAtomic.auditSubmit_$MesTemplateUpdateLock(req, mesTemplateCondition);
        }
    }

    public Mono<ServerResponse> audit(ServerRequest req, MesTemplateCondition mesTemplateCondition) {
        if (MesTemplateResUnsafeValid.audit(req, mesTemplateCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTemplateResAtomic.audit_$MesTemplateUpdateLock(req, mesTemplateCondition);
        }
    }

    public Mono<ServerResponse> auditReject(ServerRequest req, MesTemplateCondition mesTemplateCondition) {
        if (MesTemplateResUnsafeValid.auditReject(req, mesTemplateCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTemplateResAtomic.auditReject_$MesTemplateUpdateLock(req, mesTemplateCondition);
        }
    }

    public Mono<ServerResponse> usingEnable(ServerRequest req, MesTemplateCondition mesTemplateCondition) {
        if (MesTemplateResUnsafeValid.usingEnable(req, mesTemplateCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTemplateResAtomic.usingEnable_$MesTemplateUpdateLock(req, mesTemplateCondition);
        }
    }

    public Mono<ServerResponse> usingDisable(ServerRequest req, MesTemplateCondition mesTemplateCondition) {
        if (MesTemplateResUnsafeValid.usingDisable(req, mesTemplateCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesTemplateResAtomic.usingDisable_$MesTemplateUpdateLock(req, mesTemplateCondition);
        }
    }

}
